package com.itibo.services;

import java.io.File;

import java.io.FileNotFoundException;

import com.itibo.models.CSVDocument;
import com.itibo.models.Document;
import com.itibo.models.Song;
import com.itibo.models.SongCollection;


public class SongReader {
	private Document newdoc;

	public SongReader(Document doc) {
		newdoc = doc;
	}

	private Song readOneSong() {
		String[] obj = newdoc.readObject();
		if (obj != null) {
			return new Song(obj[0], obj[1], obj[2], obj[3]);
		}
		return null;
	}

	public SongCollection getSongsCollection() {
		SongCollection mySongs = new SongCollection();
		Song newSong;
		while ((newSong = readOneSong()) != null) {
			mySongs.add(newSong);
		}
		return mySongs;
	}
}
